import { createRouter, createWebHistory } from "vue-router";
import HomePage from "../pages/HomePage.vue";
import SingleCourse from "../pages/SingleCourse.vue";
import CourseList from "../pages/CourseList.vue";
import TotalClassroom from "@/pages/TotalClassroom.vue";
import AuditorPage from "@/pages/AuditorPage.vue";
import StuTotal from "@/components/Stu/StuTotal.vue";
import StuSingle from "@/components/Stu/StuSingle.vue";
import SingleClassroom from "@/pages/SingleClassroom.vue";
import PreHome from "@/pages/PreHome.vue";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      component: PreHome,
    },
    {
      path: "/HomePage",
      name: "HomePage",
      component: HomePage,
    },
    {
      path: "/singleClassroom",
      component: SingleClassroom,
      props: (route) => ({ classroomId: route.query.classroomId }),
    },
    {
      path: "/course",
      component: SingleCourse,
      props: (route) => ({ courseId: route.query.courseId }),
    },
    {
      path: "/courses",
      component: CourseList,
      props: (route) => ({ page: parseInt(route.query.page) || 1 }),
    },
    {
      path: "/classroom",
      component: TotalClassroom,
    },
    {
      path: "/auditor",
      name: "aud_page",
      component: AuditorPage,
    },
    {
      path: "/student",
      component: StuTotal,
    },
    {
      path: "/StudentSingle",
      component: StuSingle,
      props: (route) => ({ id: route.query.id }),
      //route间传参，必须加
    },
  ],
});

export default router;
